package com.easydl.project;

import java.io.File;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

public class EasyPictureClient {
	public static void main(String[] args) {
		RestTemplate restTemplate = new RestTemplate();
		//String url="http://localhost:8080/easydl/mask";
		String url = "http://127.0.0.1:8091/api/easydl/mask";
		File file=new File("F:\\mask\\7.jpg");
		HttpHeaders headers = new HttpHeaders();
		MultiValueMap<String, Object> params = new LinkedMultiValueMap<String, Object>(1);
		
		Resource resource = new FileSystemResource(file);
		params.add("file", resource);
		
		HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(params, headers);
		for(int i=0;i<2;i++) {
			ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);
			System.out.println(response.getBody());
		}
		
	}
}
